package com.server.common.util;

import javax.servlet.http.HttpServletRequest;

import com.server.common.base.PathManager;
import com.server.common.base.ProjectInfor;

public class RequestUtil {

	 /**
	 * 获取文件服务器地址
	 * @param request
	 * @return
	 * @author ServerZhang
	 * @date 2017年3月27日
	 */
	public static String getFileHost(HttpServletRequest request){
		StringBuffer serverBuffer = new StringBuffer();
		String serverName = request.getServerName();
		int serverPort = request.getServerPort();
		serverBuffer.append("http://").append(serverName)
			.append(":").append(serverPort).append("/")
			.append(PathManager.FILE_MAPPING);
		return serverBuffer.toString();
	}
	
	 /**
	 * 获取服务器地址+工程地址
	 * @param request
	 * @return
	 * @author ServerZhang
	 * @date 2017年3月27日
	 */
	public static String getServer(HttpServletRequest request){
		StringBuffer serverBuffer = new StringBuffer();
		String serverName = request.getServerName();
		int serverPort = request.getServerPort();
		serverBuffer.append("http://").append(serverName)
		.append(":").append(serverPort).append("/")
		.append(ProjectInfor.ROOT_PATH);
		return serverBuffer.toString();
	}
}
